package com.ws.app.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ws.app.service.ExpenseService;
import com.ws.base.db.common.order.Order;
import com.ws.base.db.common.page.Page;
import com.ws.base.db.support.DBSqlIdSupport;

public class ExpenseServiceImpl implements ExpenseService {
    private DBSqlIdSupport dbSqlIdSupport;

    public int addExpense(Map<String, Object> condition) {
        return dbSqlIdSupport.add("app_addExpense", condition);
    }

    public int deleteExpenseById(String id) {
        Map<String, Object> condition = new HashMap<String, Object>();
        condition.put("id", id);
        return dbSqlIdSupport.delete("app_deleteExpenseById", condition);
    }

    public int updateExpense(Map<String, Object> condition) {
        return dbSqlIdSupport.update("app_updateExpenseById", condition);
    }

    public List<Map<String, Object>> queryExpense(
            Map<String, Object> condition, Page page, Order order) {
        return dbSqlIdSupport.query("app_queryExpenseByCondition", condition,
                page, order);
    }

    @Override
    public Map<String, Object> getExpense(Map<String, Object> condition) {
        return queryExpense(condition, null, null).get(0);
    }

    public DBSqlIdSupport getDbSqlIdSupport() {
        return dbSqlIdSupport;
    }

    public void setDbSqlIdSupport(DBSqlIdSupport dbSqlIdSupport) {
        this.dbSqlIdSupport = dbSqlIdSupport;
    }
}
